<template>
	<view>
		<view v-for="(item, index) in items" :key="index">
			<view style="padding: 0px 0px;">
				<van-cell-group :title="'行程'+(item.backIndex + 1)">
					<van-cell :data-backindex="item.backIndex" title="司机" is-link :value="nameAndPhone(item)" @click="onClickDriver" />
					<van-cell  :data-backindex="item.backIndex" title="汽车" is-link :value="item.bus.number || '点击选择'" @click="onClickBus" />
				</van-cell-group>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		props:{
			items:Array,
			orderid:Number
		},
		data() {
			return {
				primaryColor:getApp().globalData.primaryColor
			};
		},
		methods:{
			nameAndPhone(item){
				console.log(item)
				if(item.driver.phone){
					return `${item.driver.name} ${item.driver.phone}`
				}
				return '点击选择'
			},
			onClickDriver(e){
				const backIndex = e.currentTarget.dataset.backindex
				uni.navigateTo({
					url:`../../pages/driver-list/driver-list?backindex=${backIndex}&orderid=${this.orderid}`
				})
			},
			onClickBus(e){
				const backIndex = e.currentTarget.dataset.backindex
				uni.navigateTo({
					url:`../../pages/mbus-list/mbus-list?backindex=${backIndex}&orderid=${this.orderid}`
				})
			}
		}
	}
</script>

<style lang="scss">

</style>
